-
Notifications
You must be signed in to change notification settings - Fork 18
Add support for custom authorization endpoints via authorizationEndpoint prop to KindeProvider #142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add support for custom authorization endpoints via authorizationEndpoint prop to KindeProvider #142
Conversation
- Expose an optional in KindeProviderProps - Use override to swap out the default path for custom endpoints (e.g. ) - Preserve all query parameters when building the redirect URL - Include in login() callback’s dependency array - Closes kinde-oss#78
WalkthroughThe Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant KindeProvider
participant AuthService
User->>KindeProvider: Initiate login
KindeProvider->>AuthService: Generate authorization URL
alt authorizationEndpoint provided
KindeProvider->>KindeProvider: Replace URL pathname with authorizationEndpoint
end
KindeProvider->>User: Redirect to (possibly overridden) authorization URL
Assessment against linked issues
Possibly related PRs
Note ⚡️ AI Code Reviews for VS Code, Cursor, WindsurfCodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/state/KindeProvider.tsx (1)
192-204
: Add error handling for URL manipulation.The custom authorization endpoint logic is well-implemented and correctly preserves query parameters while overriding the pathname. However, consider adding error handling for potential URL parsing issues.
- let redirectUrl = ""; - if (authorizationEndpoint) { - // override just the path, keep the query string - const custom = new URL(authUrl.url.toString()); - // ensure it's a path, not a full URL - custom.pathname = authorizationEndpoint.startsWith("/") - ? authorizationEndpoint - : `/${authorizationEndpoint}`; - redirectUrl = custom.toString(); - } else { - redirectUrl = authUrl.url.toString(); - } + let redirectUrl = ""; + if (authorizationEndpoint) { + try { + // override just the path, keep the query string + const custom = new URL(authUrl.url.toString()); + // ensure it's a path, not a full URL + custom.pathname = authorizationEndpoint.startsWith("/") + ? authorizationEndpoint + : `/${authorizationEndpoint}`; + redirectUrl = custom.toString(); + } catch (error) { + console.error("Error constructing custom authorization URL:", error); + redirectUrl = authUrl.url.toString(); + } + } else { + redirectUrl = authUrl.url.toString(); + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/state/KindeProvider.tsx
(17 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/state/KindeProvider.tsx (3)
src/state/KindeContext.ts (1)
KindeContextProps
(18-40)src/state/types.ts (2)
ErrorProps
(29-32)LogoutOptions
(34-37)src/utils/getRedirectUrl.ts (1)
getRedirectUrl
(1-3)
🔇 Additional comments (2)
src/state/KindeProvider.tsx (2)
88-88
: LGTM: Clean type definition for the new prop.The optional
authorizationEndpoint
property is properly typed and fits well with the existing interface structure.
128-128
: LGTM: Proper prop destructuring.The
authorizationEndpoint
prop is correctly extracted in the component parameter destructuring.
Checklist
🛟 If you need help, consider asking for advice over in the Kinde community.